<?php


namespace Xiaoguai\DesignPattern\DP023\Expression;


use Xiaoguai\DesignPattern\DP023\ExpressionInterface;

class TerminalExpression implements ExpressionInterface
{
    protected $items = [];

    /**
     * 将表达式初始化到chars
     * TerminalExpression constructor.
     * @param string[] $items
     */
    public function __construct(array $items)
    {
        $this->items = $items;
    }

    /**
     * 判断字符串是否在items中
     * @param string $char
     * @return bool
     */
    public function interpret(string $item): bool
    {
        return array_search($item, $this->items, true) !== false;
    }
}